package com.qf;

import com.alibaba.fastjson.serializer.SerializerFeature;
import com.alibaba.fastjson.support.config.FastJsonConfig;
import com.alibaba.fastjson.support.spring.FastJsonHttpMessageConverter;
import org.apache.ibatis.annotations.Mapper;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.web.HttpMessageConverters;
import org.springframework.context.annotation.Bean;
import org.springframework.http.converter.HttpMessageConverter;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

import java.util.List;

/**
 * 2019/12/4
 * Administrator
 * springboot1204
 * 面向对象面向君  不负代码不负卿
 */
//自定义的启动类,启动类必须在所有java文件的父包中定义
@SpringBootApplication
@MapperScan("com.qf.dao")
public class Begin/* extends WebMvcConfigurerAdapte*/{
@Bean
public HttpMessageConverters a1(){
    System.out.println("a1-->");
    //1.创建一个和HttpMessageConverter相关的工具类对象
    FastJsonHttpMessageConverter converter = new FastJsonHttpMessageConverter();
    //2.创建一个json配置的工具类
    FastJsonConfig config = new FastJsonConfig();
    config.setSerializerFeatures(SerializerFeature.PrettyFormat);
    //3.将配置类赋值converter
    converter.setFastJsonConfig(config);
    return new HttpMessageConverters(converter);
}


   /* @Override  //进行json格式转化的定义
    public void configureMessageConverters(List<HttpMessageConverter<?>> converters) {
        System.out.println("configureMessageConverters-->");
        //1.创建一个和HttpMessageConverter相关的工具类对象
        FastJsonHttpMessageConverter converter = new FastJsonHttpMessageConverter();
        //2.创建一个json配置的工具类
        FastJsonConfig config = new FastJsonConfig();
        config.setSerializerFeatures(SerializerFeature.PrettyFormat);
        //3.将配置类赋值converter
        converter.setFastJsonConfig(config);
        //4.建立对象绑定
        converters.add(converter);
    }*/



    public static void main(String[] args) {
        // SpringApplication.run(当前类名.class,args);
       SpringApplication.run(Begin.class,args);
    }
}
